package edu.whut.mall.portal.service;

import edu.whut.mall.common.api.CommonPage;
import edu.whut.mall.portal.dto.GroupBuyQualificationResult;
import edu.whut.mall.portal.vo.*;

import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @program: d9lab-mall
 * @description: 用户团购接口
 * @author: Wayne
 * @create: 2020-05-17 20:41
 **/
public interface IPortalGroupBuyService {
    /**
     * 列出所有的团购分类
     * @return
     */
    CommonPage<GroupBuyCategoryVo> listGroupBuyCategoryVos(Integer pageNum, Integer size);

    /**
     * 根据团购分类id获取团购规则
     * @param categoryId
     * @param pageNum
     * @param size
     * @return
     */
    CommonPage<GroupBuyRuleVo> listGroupBuyRuleVosByCategoryId(Long categoryId, Integer pageNum, Integer size);

    /**
     * 发起团购
     * @param userId
     * @param groupBuyRuleId
     * @return
     */
    GroupBuyQualificationResult createGroupBuyRecord(Long userId, Long groupBuyRuleId, String orderId) throws NoSuchAlgorithmException;

    /**
     * 加入团购
     * @param userId
     * @param groupBuyRecordId
     * @param orderId
     * @return
     */
    GroupBuyQualificationResult joinGroupBuyRecord(Long userId, Long groupBuyRecordId, String orderId) throws NoSuchAlgorithmException;

    /**
     * 根据订单号来完成全额退款
     * @param orderNo
     */
    void refundGroupBuyRecord(String orderNo) throws NoSuchAlgorithmException;

    /**
     * 是否有资格参加这次团购
     * 失败的原因 例如
     * 1.已经超过了限购次数
     * 等等
     * @param userId
     * @param recordId
     * @params ruleLimitNumber
     * @return
     */
    GroupBuyQualificationResult isQualifiedToJoinGroupBuyRecord(Long userId, Long recordId, Integer ruleLimitNumber);

    /**
     * 是否有资格开启团购
     * @param userId
     * @param ruleId
     */
    GroupBuyQualificationResult isQualifiedToCreateGroupBuyRecord(Long userId, Long ruleId);

    /**
     * 根据recordId获取团购订单详情
     * @param recordId
     * @return
     */
    GroupBuyRecordDetailVo getGroupBuyRecordDetailVoByRecordId(Long recordId);

    /**
     * 根据规则id获取规则详情
     * @param ruleId
     * @return
     */
    GroupBuyRuleDetailVo getGroupBuyRuleDetailVosByRuleId(Long ruleId);
    /**
     * 获取所有商品分类
     * @return
     */
    List<ProductCategoryVo> listProductCategoryVos();

    /**
     * 根据商品分类来获取团购规则
     * @param categoryId
     * @return
     */
    List<GroupBuyRuleVo> listGroupBuyRuleVosByProductCategory(Long categoryId);

    /**
     * 根据商品名称来搜索团购
     * @param productName
     * @return
     */
    List<GroupBuyRuleVo> getGroupBuyRuleVoBySearchingName(String productName);

}
